package jax.lang;

/**
 * ...
 * @author tom
 */
class JStringBuilder implements JCharSequence {
	var _native:StringBuf;
	public function new (?f:Dynamic) {
		_native = new StringBuf();
		if(f != null && Std.is(f, JCharSequence))
			_native.add(f.toString());
		else if(Std.is(f, String))
			_native.add(f);
	}
	public function append(d:Dynamic) {
		_native.add(d);
		return this;
	}
	public function charAt(ind:haxe.Int32):Int {
		return _native.toString().charCodeAt(haxe.Int32.toInt(ind));
	}
	public function length():Int {
		return _native.toString().length;
	}
	public function toString():String {
		return _native.toString();
	}
	public function subSequence(s:haxe.Int32, e:haxe.Int32) {
		return new jax.lang.JString(toString().substr(haxe.Int32.toInt(s), haxe.Int32.toInt(haxe.Int32.sub(e, s))));
	}
}
